package czh.cocoa.foundation;

public class NSNumber extends NSValue {

	private float mValue;
	
	public NSNumber(int num) {
		mValue = num;
	}
	
	public NSNumber(float num) {
		mValue = num;
	}
	
	public NSNumber(boolean num) {
		mValue = num ? 1 : 0;
	}
	
	public int intValue() {
		return (int) mValue;
	}
	
	public float floatValue() {
		return mValue;
	}
	
	public boolean boolValue() {
		return mValue != 0;
	}
	
	public boolean isEqual(NSObject o) {
		if (o instanceof NSNumber) {
			NSNumber other = (NSNumber) o;
			return mValue == other.mValue;
		}
		return false;
	}
	
	public int hash() {
		return (int) (mValue * 1000);
	}
	
	public NSString description() {
		return NSTR("" + mValue);
	}
	
}
